package day6;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author oldliu
 * @since 1.0
 */
public class MApTest {
    public static void main(String[] args) {
        Map<String, String> m = new HashMap<>();
        m.put("one", "一");
        m.put("dog", "狗");
        m.put("yes", "是");
        m.put("cat", "猫");
        System.out.println(m.size());
        System.out.println(m);
        boolean d = m.containsKey("dog");
        System.out.println(d);
        String v = m.remove("dog");//返回value，没有,返回null

        System.out.println(v);
        System.out.println(">>>>>>怎么迭代整个Map>>>>>>>>>");
        System.out.println("1:::::::::::::::::::::::::");
        Set<String> set = m.keySet();//键集合
        //m.values();//值集合
        for(String s:set){
            System.out.println(s+"="+m.get(s));
        }
        System.out.println("2::::::::::::::::::::::::");
        Set<Map.Entry<String, String>> entries = m.entrySet();
        for(Map.Entry<String, String> en:entries){
            System.out.println(en.getKey()+"=="+en.getValue());
        }
    }
}
